package com.ie.cloud.payment.init;

import com.ie.cloud.payment.cache.RedisUtil;
import com.ie.cloud.payment.constants.CS;
import com.ie.cloud.payment.entity.RefundOrder;
import com.ie.cloud.payment.mapper.RefundOrderMapper;
import com.ie.cloud.payment.service.impl.RefundOrderServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with FR
 *
 * @Author: DQ
 * @Date: 2025/07/24/16:04
 * @Description: 退款订单号缓存初始化
 */
@Component
@Slf4j
public class RefundPayOrderIdCacheInit implements CommandLineRunner {

    @Resource
    private RefundOrderMapper refundOrderMapper;


    @Override
    public void run(String... args) throws Exception {

        List<RefundOrder> refundOrders = refundOrderMapper.selectList(RefundOrder.gw());
        log.info("退款订单号缓存初始化启动");

        for (RefundOrder refundOrder : refundOrders) {
            RedisUtil.setObject(CS.getCacheKeyRefundOrderId(refundOrder.getMchRefundNo()),refundOrder.getPayOrderId());
        }

        log.info("退款订单号缓存初始化完成");

    }
}
